package com.base.config.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.FilterConfig;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 开发公司：个人
 * 版权：个人
 * <p>
 * MainFilter
 * @WebFilter(filterName = "mainFilter", urlPatterns = {"/*"})
 * filterName 过滤器名称 urlPatterns 需要过滤的url
 * @author 刘志强
 * @created Create Time: 2019/5/25
 */

@WebFilter(filterName = "mainFilter", urlPatterns = {"/*"})
public class MainFilter implements Filter {

    protected Logger logger = LoggerFactory.getLogger(getClass());


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("过滤器创建");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        logger.info("执行过滤请求");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        logger.info("过滤器销毁");
    }
}